<?php
namespace app\common\model;

use think\Model;
use think\Db;

/**
 * 业务类型
 * @author lcx
 */
class BusinessTypeModel extends Model
{
    protected $name = 'business_type';

    // 列表查询
    public function getlist($where, $field, $page, $pageSize, $order)
    {
        $result = Db::name($this->name)
                    ->where($where)
                    ->field($field)
                    ->page($page, $pageSize)
                    ->order($order)
                    ->select();
        return $result;
    }

    // 数量统计
    public function getCount($where)
    {
        $result = $this->where($where)->count();
        return $result;
    }

    // 单条查询
    public function getOne($where, $field = '*')
    {
        $result = Db::name($this->name)
                    ->where($where)
                    ->field($field)
                    ->find();
        return $result;
    }

    // 修改
    public function edit($where, $data)
    {
        $result = $this->where($where)->update($data);
        return $result;
    }

    /**
     * 查询所有工单业务类型
     * @param type $where
     * @param type $field
     * @param type $join
     * @param type $order
     * @return type
     */
    public function getAll($where = [],$field = '*',$join=[],$order='sort asc')
    {
        $data = $this ->join($join)         
                ->field($field)             
                ->where($where)
                ->order($order)
                ->select();
        // 返回结果
        return $data;
    }
}
